package com.minesweeper;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MainMenu {
    private Stage primaryStage;
    private GameBoardFactory gameBoardFactory;

    public MainMenu(Stage primaryStage) {
        this.primaryStage = primaryStage;
        this.gameBoardFactory = new GameBoardFactory();
    }

    public void show() {
        VBox vbox = new VBox(10);
        vbox.setPadding(new Insets(10));

        Label title = new Label("扫雷游戏");
        Button easyButton = new Button("简单难度");
        easyButton.setOnAction(e -> startGame(Difficulty.EASY));
        Button mediumButton = new Button("中等难度");
        mediumButton.setOnAction(e -> startGame(Difficulty.MEDIUM));
        Button hardButton = new Button("困难难度");
        hardButton.setOnAction(e -> startGame(Difficulty.HARD));
        Button helpButton = new Button("游戏帮助");
        helpButton.setOnAction(e -> showHelp());

        vbox.getChildren().addAll(title, easyButton, mediumButton, hardButton, helpButton);

        Scene scene = new Scene(vbox, 200, 250);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    private void startGame(Difficulty difficulty) {
        GameBoard gameBoard = gameBoardFactory.createGameBoard(difficulty);
        GameView gameView = new GameView(primaryStage, gameBoard);
        gameView.show();
    }

    private void showHelp() {
        HelpDialog.show();
    }
}